package self.example.explore.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

/**
 * @author 1.
 * @version 1.0
 * @description:  定时任务调度器配置类
 * @date 2023/4/12 19:41
 */
@Configuration
public class TaskSchedulerConfigure implements SchedulingConfigurer {
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        // spring scheduler 内部的线程池实现类
        final ThreadPoolTaskScheduler poolTaskScheduler = new ThreadPoolTaskScheduler();
        poolTaskScheduler.setPoolSize(3);
        poolTaskScheduler.initialize();
        taskRegistrar.setTaskScheduler(poolTaskScheduler); //配置线程池
    }
}
